/*#####################################*/
// Project Name : JSmartKit
// Author : Mr.Surachai Yindeeram
// Office : BrainStream Co.,Ltd.
// Create Date : Jan 3, 2013 3:53:04 PM
// Description : Server.java
/*#####################################*/
package com.xpaac.server;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

public class Server {
	/**
	 * get client ip address direct/proxy
	 *@return
	 */
	public static String getRemoteAddress(){
		HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();  
		String ipAddress = httpServletRequest.getRemoteAddr();
		if (ipAddress.length() < 4 && ipAddress.length() > 12) {
			ipAddress = httpServletRequest.getHeader( "X_FORWARDED_FOR" );
		}
		return ipAddress;
	}
	
	
}
